#include "pig.h"
#include "ui_pig.h"

#include <QApplication>

#include "sdk_framework_api.h"
#include <QtCore/QDebug>
#include <QtCore/QDateTime>
#include <thread>

int main(int argc, char *argv[])
{
    // (1) Framework Context Initialization
    const eintik::ScopedFramework *p_framework = new eintik::ScopedFramework();
    auto &framework = *p_framework;

    // (2) Qt framework
    QApplication a(argc, argv);

    // (3) UI Framework and Components
    Pig *pig_pipe = nullptr;
    if (const auto config = framework.config();
        config->GetStartMode() == "client" || config->GetStartMode() == "combo") {
        pig_pipe = new Pig();
        pig_pipe->Init();
        pig_pipe->showMaximized();
    }

    // (4) Qt Message loop
    const auto ret = a.exec();

    if (pig_pipe) {

        delete pig_pipe;
    }

    delete p_framework;

    return ret;
}
